/*class MyCircularQueue {
    public int[] array;
    private int front;
    private int rear;
    public MyCircularQueue(int k) {
        array = new int[k + 1];
    }
    //插入数据
    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }
        else{
            array[rear] = value;
            //不可以单纯的rear++;会溢出，就不是循环了
            rear = (rear + 1) % array.length;
            return true;
        }
    }
    //删除元素
    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }
        front = (front + 1) % array.length;
        return true;
    }

    public int Front() {
        if(isEmpty()){
            return -1;
        }
        return array[front];
    }

    public int Rear() {
        if(isEmpty()){
            return -1;
        }
        return rear == 0 ? array[array.length - 1] : array[rear - 1];
    }

    public boolean isEmpty() {
        if(rear == front){
            return true;
        }
        return false;
    }

    public boolean isFull() {
        return (rear + 1) % array.length == front;
    }
}*/
class MyCircularQueue {
    public int[] array;
    private int front;
    private int rear;
    private int usedSize;
    public MyCircularQueue(int k) {
        array = new int[k];
    }
    //插入数据
    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }
        else{
            array[rear] = value;
            //不可以单纯的rear++;会溢出，就不是循环了
            rear = (rear + 1) % array.length;
            usedSize++;
            return true;
        }
    }
    //删除元素
    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }
        front = (front + 1) % array.length;
        usedSize--;
        return true;
    }

    public int Front() {
        if(isEmpty()){
            return -1;
        }
        return array[front];
    }

    public int Rear() {
        if(isEmpty()){
            return -1;
        }
        return rear == 0 ? array[array.length - 1] : array[rear - 1];
    }

    public boolean isEmpty() {
        if(usedSize == 0){
            return true;
        }
        return false;
    }

    public boolean isFull() {
        return usedSize == array.length;
    }
}